using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace Main.controls
{
    public partial class AddFriend : System.Web.UI.UserControl
    {
        private string _PostBackURL = "";
        public string PostBackURL
        {
            get
            { return _PostBackURL; }
            set
            { _PostBackURL = value; }
        }
        private Guid _UserID;
        public Guid UserID
        {
            get
            { return _UserID; }
            set
            { _UserID = value; }
        }
        private Guid _FriendID;
        public Guid FriendID
        {
            get
            { return _FriendID; }
            set
            { _FriendID = value; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            
            modifyFriend.PostBackUrl = PostBackURL;
            //We need to setup the button.
            //First, we need to know if that friendship exists.
            if (Friend.DoesFriendShipExist(UserID, FriendID))
            {
                //Yay, they are friends.
                //let's set the button text.
                modifyFriend.Text = "Remove Friend";
            }
            else
            {
               //So it doesn't...
                //Well, we need to set somethings up.
                modifyFriend.Text = "Add Friend";
                //Next, we need to see if they clicked the button
                if (IsPostBack)
                {
                    Friend newFriends = new Friend();
                    newFriends.UserID = UserID;
                    newFriends.FriendID = FriendID;
                    newFriends.Commit();
                    Response.Redirect(PostBackURL);
                }
            }
            
        }
    }
}